<template>
	<view>
		<view class="1">
			<u-search :show-action="true" actionText="搜索" :animation="true"></u-search>
		</view>
		<br>
		<template>
			<u-subsection :list="list" :current="curNow" @change="sectionChange1"></u-subsection>
		</template>
		<view v-if="curNow==0">
			<uni-card v-for="(item,index) in approveList" :key="index" @click="mine(item.id)"
				v-show="item.enclosure==1 & item.spid==1" v-if="emplevels==3">
				<uni-title type="h3" title="入职申请"></uni-title>
				<text>入职员工:{{item.ename}}</text>
				<br>
				<text>入职部门:{{item.department}}</text>
				<br>
				<view>
					<text>提交人:{{item.name}}</text>
				</view>
				<view>
					<text>提交时间:{{aa(item.createtime)}}</text>
				</view>
				<view v-show="item.spid==1">
					审批状态：<span style="color: red;">审批中</span>
				</view>
			</uni-card>
			<uni-card @click="mine(item.id)" v-for="item in approveList" v-show="item.enclosure==2 & item.spid==1"
				v-if="emplevels==3">
				<uni-title type="h3" title="转正申请"></uni-title>
				<text>入职员工:{{item.ename}}</text>
				<br>
				<text>入职部门:{{item.department}}</text>
				<br>
				<view class="">
					<text>提交人:{{item.name}}</text>
				</view>
				<view class="">
					<text>提交时间: {{aa(item.createtime)}}</text>
				</view>
				<view class="" v-show="item.spid==1">
					审批状态：<span style="color: red;">审批中</span>
				</view>
			</uni-card>
			<uni-card @click="mine(item.id)" v-for="item in approveList" v-show="item.enclosure==3 & item.spid==1"
				v-if="emplevels==3">
				<uni-title type="h3" title="调动申请"></uni-title>
				<text>入职员工:{{item.ename}}</text>
				<br>
				<text>入职部门:{{item.department}}</text>
				<br>
				<view class="">
					<text>提交人:{{item.name}}</text>
				</view>
				<view class="">
					<text>提交时间:{{aa(item.createtime)}}</text>
				</view>
				<view class="" v-show="item.spid==1">
					审批状态：<span style="color: red;">审批中</span>
				</view>
			</uni-card>
			<uni-card @click="mine(item.id)" v-for="item in approveList" v-show="item.enclosure==4 & item.spid==1"
				v-if="emplevels==3">
				<uni-title type="h3" title="离职申请"></uni-title>
				<text>入职员工:{{item.ename}}</text>
				<br>
				<text>入职部门:{{item.department}}</text>
				<br>
				<view class="">
					<text>提交人:{{item.name}}</text>
				</view>
				<view class="">
					<text>提交时间:{{aa(item.createtime)}}</text>
				</view>
				<view class="" v-show="item.spid==1">
					审批状态：<span style="color: red;">审批中</span>
				</view>
			</uni-card>
			<uni-card @click="mine(item.id)" v-for="item in approveList" v-show="item.enclosure==5 & item.spid==1"
				v-if="emplevels==3">
				<uni-title type="h3" title="招聘申请"></uni-title>
				<text>入职员工:{{item.ename}}</text>
				<br>
				<text>入职部门:{{item.department}}</text>
				<br>
				<view class="">
					<text>提交人:{{item.name}}</text>
				</view>
				<view class="">
					<text>提交时间:{{aa(item.createtime)}}</text>
				</view>
				<view class="" v-show="item.spid==1">
					审批状态：<span style="color: red;">审批中</span>
				</view>
			</uni-card>
			<uni-card @click="mine(item.id)" v-for="item in approveList" v-show="item.enclosure==6 & item.spid==1"
				v-if="emplevels==3">
				<uni-title type="h3" title="补卡申请"></uni-title>
				<text>入职员工:{{item.ename}}</text>
				<br>
				<text>入职部门:{{item.department}}</text>
				<br>
				<view class="">
					<text>提交人:{{item.name}}</text>
				</view>
				<view class="">
					<text>提交时间:{{aa(item.createtime)}}</text>
				</view>
				<view class="" v-show="item.spid==1">
					审批状态：<span style="color: red;">审批中</span>
				</view>
			</uni-card>
			<uni-card @click="mine(item.id)" v-for="item in approveList" v-show="item.enclosure==7 & item.spid==1"
				v-if="emplevels==3">
				<uni-title type="h3" title="请假申请"></uni-title>
				<text>入职员工:{{item.ename}}</text>
				<br>
				<text>入职部门:{{item.department}}</text>
				<br>
				<view class="">
					<text>提交人:{{item.name}}</text>
				</view>
				<view class="">
					<text>提交时间:{{aa(item.createtime)}}</text>
				</view>
				<view class="" v-show="item.spid==1">
					审批状态：<span style="color: red;">审批中</span>
				</view>
			</uni-card>
			<uni-card @click="mine(item.id)" v-for="item in approveList" v-show="item.enclosure==8 & item.spid==1"
				v-if="emplevels==3">
				<uni-title type="h3" title="加班申请"></uni-title>
				<text>入职员工:{{item.ename}}</text>
				<br>
				<text>入职部门:{{item.department}}</text>
				<br>
				<view class="">
					<text>提交人:{{item.name}}</text>
				</view>
				<view class="">
					<text>提交时间:{{aa(item.createtime)}}</text>
				</view>
				<view class="" v-show="item.spid==1">
					审批状态：<span style="color: red;">审批中</span>
				</view>
			</uni-card>
			<uni-card @click="mine(item.id)" v-for="item in approveList" v-show="item.enclosure==9 & item.spid==1"
				v-if="emplevels==3">
				<uni-title type="h3" title="出差申请"></uni-title>
				<text>入职员工:{{item.ename}}</text>
				<br>
				<text>入职部门:{{item.department}}</text>
				<br>
				<view class="">
					<text>提交人:{{item.name}}</text>
				</view>
				<view class="">
					<text>提交时间:{{aa(item.createtime)}}</text>
				</view>
				<view class="" v-show="item.spid==1">
					审批状态：<span style="color: red;">审批中</span>
				</view>
			</uni-card>
			<uni-card @click="mine(item.id)" v-for="item in approveList" v-show="item.enclosure==10 & item.spid==1"
				v-if="emplevels==3">
				<uni-title type="h3" title="费用报销申请"></uni-title>
				<text>入职员工:{{item.ename}}</text>
				<br>
				<text>入职部门:{{item.department}}</text>
				<br>
				<view class="">
					<text>提交人:{{item.name}}</text>
				</view>
				<view class="">
					<text>提交时间:{{aa(item.createtime)}}</text>
				</view>
				<view class="" v-show="item.spid==1">
					审批状态：<span style="color: red;">审批中</span>
				</view>
			</uni-card>
			<uni-card @click="mine(item.id)" v-for="item in approveList" v-show="item.enclosure==11 & item.spid==1"
				v-if="emplevels==3">
				<uni-title type="h3" title="付款申请"></uni-title>
				<text>入职员工:{{item.ename}}</text>
				<br>
				<text>入职部门:{{item.department}}</text>
				<br>
				<view class="">
					<text>提交人:{{item.name}}</text>
				</view>
				<view class="">
					<text>提交时间:{{aa(item.createtime)}}</text>
				</view>
				<view class="" v-show="item.spid==1">
					审批状态：<span style="color: red;">审批中</span>
				</view>
			</uni-card>
			<uni-card @click="mine(item.id)" v-for="item in approveList" v-show="item.enclosure==12 & item.spid==1"
				v-if="emplevels==3">
				<uni-title type="h3" title="合同申请"></uni-title>
				<text>入职员工:{{item.ename}}</text>
				<br>
				<text>入职部门:{{item.department}}</text>
				<br>
				<view class="">
					<text>提交人:{{item.name}}</text>
				</view>
				<view class="">
					<text>提交时间:{{aa(item.createtime)}}</text>
				</view>
				<view class="" v-show="item.spid==1">
					审批状态：<span style="color: red;">审批中</span>
				</view>
			</uni-card>
			<uni-card @click="mine(item.id)" v-for="item in approveList" v-show="item.enclosure==13 & item.spid==1"
				v-if="emplevels==3">
				<uni-title type="h3" title="备用金申请"></uni-title>
				<text>入职员工:{{item.ename}}</text>
				<br>
				<text>入职部门:{{item.department}}</text>
				<br>
				<view class="">
					<text>提交人:{{item.name}}</text>
				</view>
				<view class="">
					<text>提交时间:{{aa(item.createtime)}}</text>
				</view>
				<view class="" v-show="item.spid==1">
					审批状态：<span style="color: red;">审批中</span>
				</view>
			</uni-card>
		</view>
		<view class="" v-else>
			<uni-card @click="ago(item.id)" v-for="item in approveList"
				v-show="item.enclosure==1 & item.spid!=1" v-if="emplevels==3">
				<uni-title type="h3" title="入职申请"></uni-title>
				<text>入职员工:{{item.ename}}</text>
				<br>
				<text>入职部门:{{item.department}}</text>
				<br>
				<view class="">
					<text>提交人:{{item.name}}</text>
				</view>
				<view class="">
					<text>提交时间:{{aa(item.createtime)}}</text>
				</view>
				<view v-show="item.spid!=1" >
					审批状态：<span style="color: green;">审批完成</span>
				</view>
			</uni-card>
			<uni-card @click="ago(item.id)" v-for="item in approveList"
				v-show="item.enclosure==2 & item.spid!=1" v-if="emplevels==3">
				<uni-title type="h3" title="转正申请"></uni-title>
				<text>入职员工:{{item.ename}}</text>
				<br>
				<text>入职部门:{{item.department}}</text>
				<br>
				<view class="">
					<text>提交人:{{item.name}}</text>
				</view>
				<view class="">
					<text>提交时间:{{aa(item.createtime)}}</text>
				</view>
				<view v-show="item.spid==2 || item.spid==3 || item.spid==4" >
					审批状态：<span style="color: green;">审批完成</span>
				</view>
			</uni-card>
			<uni-card @click="ago(item.id)" v-for="item in approveList"
				v-show="item.enclosure==3 & item.spid!=1" v-if="emplevels==3">
				<uni-title type="h3" title="调动申请"></uni-title>
				<text>入职员工:{{item.ename}}</text>
				<br>
				<text>入职部门:{{item.department}}</text>
				<br>
				<view class="">
					<text>提交人:{{item.name}}</text>
				</view>
				<view class="">
					<text>提交时间:{{aa(item.createtime)}}</text>
				</view>
				<view v-show="item.spid!=1" >
					审批状态：<span style="color: green;">审批完成</span>
				</view>
			</uni-card>
			<uni-card @click="ago(item.id)" v-for="item in approveList"
				v-show="item.enclosure==4 & item.spid!=1" v-if="emplevels==3">
				<uni-title type="h3" title="离职申请"></uni-title>
				<text>入职员工:{{item.ename}}</text>
				<br>
				<text>入职部门:{{item.department}}</text>
				<br>
				<view class="">
					<text>提交人:{{item.name}}</text>
				</view>
				<view class="">
					<text>提交时间:{{aa(item.createtime)}}</text>
				</view>
				<view v-show="item.spid!=1" >
					审批状态：<span style="color: green;">审批完成</span>
				</view>
			</uni-card>
			<uni-card @click="ago(item.id)" v-for="item in approveList"
				v-show="item.enclosure==5 & item.spid!=1" v-if="emplevels==3">
				<uni-title type="h3" title="招聘申请"></uni-title>
				<text>入职员工:{{item.ename}}</text>
				<br>
				<text>入职部门:{{item.department}}</text>
				<br>
				<view class="">
					<text>提交人:{{item.name}}</text>
				</view>
				<view class="">
					<text>提交时间:{{aa(item.createtime)}}</text>
				</view>
				<view v-show="item.spid !=1" >
					审批状态：<span style="color: green;">审批完成</span>
				</view>
			</uni-card>
			<uni-card @click="ago(item.id)" v-for="item in approveList"
				v-show="item.enclosure==6 & item.spid !=1 " v-if="emplevels==3">
				<uni-title type="h3" title="补卡申请"></uni-title>
				<text>入职员工:{{item.ename}}</text>
				<br>
				<text>入职部门:{{item.department}}</text>
				<br>
				<view class="">
					<text>提交人:{{item.name}}</text>
				</view>
				<view class="">
					<text>提交时间:{{aa(item.createtime)}}</text>
				</view>
				<view v-show="item.spid !=1" >
					审批状态：<span style="color: green;">审批完成</span>
				</view>
			</uni-card>
			<uni-card @click="ago(item.id)" v-for="item in approveList"
				v-show="item.enclosure==7 & item.spid!=1" v-if="emplevels==3">
				<uni-title type="h3" title="请假申请"></uni-title>
				<text>入职员工:{{item.ename}}</text>
				<br>
				<text>入职部门:{{item.department}}</text>
				<br>
				<view class="">
					<text>提交人:{{item.name}}</text>
				</view>
				<view class="">
					<text>提交时间:{{aa(item.createtime)}}</text>
				</view>
				<view v-show="item.spid !=1" >
					审批状态：<span style="color: green;">审批完成</span>
				</view>
			</uni-card>
			<uni-card @click="ago(item.id)" v-for="item in approveList"
				v-show="item.enclosure==8 & item.spid !=1" v-if="emplevels==3">
				<uni-title type="h3" title="加班申请"></uni-title>
				<text>入职员工:{{item.ename}}</text>
				<br>
				<text>入职部门:{{item.department}}</text>
				<br>
				<view class="">
					<text>提交人:{{item.name}}</text>
				</view>
				<view class="">
					<text>提交时间:{{aa(item.createtime)}}</text>
				</view>
				<view v-show="item.spid !=1" >
					审批状态：<span style="color: green;">审批完成</span>
				</view>
			</uni-card>
			<uni-card @click="ago(item.id)" v-for="item in approveList"
				v-show="item.enclosure==9 & item.spid !=1" v-if="emplevels==3">
				<uni-title type="h3" title="出差申请"></uni-title>
				<text>入职员工:{{item.ename}}</text>
				<br>
				<text>入职部门:{{item.department}}</text>
				<br>
				<view class="">
					<text>提交人:{{item.name}}</text>
				</view>
				<view class="">
					<text>提交时间:{{aa(item.createtime)}}</text>
				</view>
				<view v-show="item.spid==2 || item.spid==3 || item.spid==4" >
					审批状态：<span style="color: green;">审批完成</span>
				</view>
			</uni-card>
			<uni-card @click="ago(item.id)" v-for="item in approveList"
				v-show="item.enclosure==10 & item.spid !=1" v-if="emplevels==3">
				<uni-title type="h3" title="费用报销申请"></uni-title>
				<text>入职员工:{{item.ename}}</text>
				<br>
				<text>入职部门:{{item.department}}</text>
				<br>
				<view class="">
					<text>提交人:{{item.name}}</text>
				</view>
				<view class="">
					<text>提交时间:{{aa(item.createtime)}}</text>
				</view>
				<view v-show="item.spid !=1" >
					审批状态：<span style="color: green;">审批完成</span>
				</view>
			</uni-card>
			<uni-card @click="ago(item.id)" v-for="item in approveList"
				v-show="item.enclosure==11 & item.spid !=1">
				<uni-title type="h3" title="付款申请"></uni-title>
				<text>入职员工:{{item.ename}}</text>
				<br>
				<text>入职部门:{{item.department}}</text>
				<br>
				<view class="">
					<text>提交人:{{item.name}}</text>
				</view>
				<view class="">
					<text>提交时间:{{aa(item.createtime)}}</text>
				</view>
				<view v-show="item.spid !=1" >
					审批状态：<span style="color: green;">审批完成</span>
				</view>
			</uni-card>
			<uni-card @click="ago(item.id)" v-for="item in approveList"
				v-show="item.enclosure==12 & item.spid!= 1" v-if="emplevels==3">
				<uni-title type="h3" title="合同申请"></uni-title>
				<text>入职员工:{{item.ename}}</text>
				<br>
				<text>入职部门:{{item.department}}</text>
				<br>
				<view class="">
					<text>提交人:{{item.name}}</text>
				</view>
				<view class="">
					<text>提交时间:{{aa(item.createtime)}}</text>
				</view>
				<view v-show="item.spid !=1" >
					审批状态：<span style="color: green;">审批完成</span>
				</view>
			</uni-card>
			<uni-card @click="ago(item.id)" v-for="item in approveList"
				v-show="item.enclosure==13 & item.spid !=1" v-if="emplevels==3">
				<uni-title type="h3" title="备用金申请"></uni-title>
				<text>入职员工:{{item.ename}}</text>
				<br>
				<text>入职部门:{{item.department}}</text>
				<br>
				<view class="">
					<text>提交人:{{item.name}}</text>
				</view>
				<view class="">
					<text>提交时间:{{aa(item.createtime)}}</text>
				</view>
				<view v-show="item.spid==2 || item.spid==3 || item.spid==4" >
					审批状态：<span style="color: green;">审批完成</span>
				</view>
			</uni-card>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				emplevels: '',
				eid: '',
				user: {},
				approveList: [],
				list: [{
						name: '待审批',
					},
					{
						name: '已审批',
					}
				],
				curNow: 0,
			}
		},
		onLoad(res) {
			this.users();
			console.log(res.eid)
			this.eid = res.eid
			this.emplevels = this.user.emplevels
			console.log(this.emplevels)
			this.selectinfo()
		},

		methods: {
			aa(date){
				const dateTime = new Date(date)
				const YY = dateTime.getFullYear()
				const MM =
					dateTime.getMonth() + 1 < 10 ? '0' + (dateTime.getMonth() + 1) : dateTime.getMonth() + 1
				const DD =
					dateTime.getDate() < 10 ? '0' + dateTime.getDate() : dateTime.getDate()
				const hh =
					dateTime.getHours() < 10 ? '0' + dateTime.getHours() : dateTime.getHours()
				const mm =
					dateTime.getMinutes() < 10 ? '0' + dateTime.getMinutes() : dateTime.getMinutes()
				const ss =
					dateTime.getSeconds() < 10 ? '0' + dateTime.getSeconds() : dateTime.getSeconds()
				return `${YY}-${MM}-${DD}`
			},
				
			users() {
				this.user = uni.getStorageSync('user')
				console.log(this.user)
			},
			sectionChange1(index) {
				this.curNow = index;
			},
			mine(id) {
				uni.navigateTo({
					url: "./mine?id=" + id
				})
			},
			ago(id) {
				uni.navigateTo({
					url: "./ago?id=" +id
				})
			},
			selectinfo() {
				uni.request({
					url: 'http://localhost:9525/aduit/approve/selectapr?eid=' + this.eid,
					method: 'POST',
					success: (res) => {
						this.approveList = res.data.data.list
					},
				});
			},
		}
	}
</script>

<style>

</style>
